package exam.beike.S3;

import java.util.Scanner;

public class Main {

    public static int n;
    public static String str;
    public static char[][] graph;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        sc.nextLine();
        str = sc.nextLine();
        graph = new char[n][n];
        for (int i = 0; i < n; i++) {
            String s = sc.nextLine();
            graph[i] = s.toCharArray();
        }
        System.out.println(count());
    }

    public static int count() {
        int num = 0;
        for (int i=0; i<n; ++i) {
            num += getCount(graph[i]);
        }
        for (int i=0; i<n; ++i) {
            num += getCountCol(i);
        }
        return num;
    }

    public static int getCount(char[] chars) {
        int num = 0;
        for (int i=0; i<=n-str.length(); ++i) {
            boolean flag = true;
            for (int j=0; j<str.length(); ++j) {
                if (str.charAt(j) != chars[i+j]) {
                    flag = false;
                    break;
                }
            }
            if (flag)
                num++;
        }
        return num;
    }

    public static int getCountCol(int col) {
        int num = 0;
        for (int i=0; i<=n-str.length(); ++i) {
            boolean flag = true;
            for (int j=0; j<str.length(); ++j) {
                if (str.charAt(j) != graph[i+j][col]) {
                    flag = false;
                    break;
                }
            }
            if (flag)
                num++;
        }
        return num;
    }
}
